<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class="aui-header-2 aui-gutter-column-md">
    <h2>{{'common_basic_info_label' | i18n}}</h2>
</div>
<resoure-base-info [source]="source" [sourceType]="source.sub_type || source.subType"></resoure-base-info>

<div class="aui-header-2 aui-gutter-column-md">
    <h2>{{'common_protected_object_label' | i18n}}</h2>
</div>
<div class="content-container fileset-summary-tree"
    *ngIf="(source.environment_name || source?.environment?.name) && showProtectedInfos">
    <div class="tree">
        <lv-datatable #lvTable [lvData]="selectionPath" [lvPaginator]="page" lvSize="small">
            <thead>
                <tr>
                    <th lvCellKey="name" lvShowCustom>
                        {{'common_path_label' | i18n}}
                    </th>
                    <th *ngIf="this.isVolumeWindows">
                        <span lv-overflow>{{
                            'common_volume_size_label' | i18n
                            }}</span>
                    </th>
                    <th *ngIf="this.isVolumeWindows">
                        <span lv-overflow>
                            {{ 'protection_file_system_type_label' | i18n }}
                        </span>
                    </th>
                </tr>
            </thead>
            <tbody>
                <ng-container *ngFor="let item of lvTable.renderData">
                    <tr>
                        <td>
                            <span lv-overflow>{{item.name}}</span>
                        </td>
                        <td *ngIf="this.isVolumeWindows">
                            <span lv-overflow class="path-overflow">
                                {{
                                !!item?.size
                                ? (item.size
                                | capacityCalculateLabel
                                : '1.1-3'
                                : unitconst.BYTE
                                : true)
                                : '--'
                                }}
                            </span>
                        </td>
                        <td *ngIf="this.isVolumeWindows">
                            <span lv-overflow>
                                {{ item.fileSystem | nil }}
                            </span>
                        </td>
                    </tr>
                </ng-container>
            </tbody>
        </lv-datatable>
        <div class="aui-paginator-wrap">
            <lv-paginator [lvTotal]="selectionPath.length" #page lvMode="simple" [lvPageSize]="pageSize"
                [lvShowPageSizeOptions]='false' [lvPageSizeOptions]="pageSizeOptions">
            </lv-paginator>
        </div>
    </div>
</div>
<div class="performance-no-data aui-block"
    *ngIf="(!source.environment_name || !showProtectedInfos) && source.subType !== dataMap.Resource_Type.volume.value">
    <lv-empty></lv-empty>
</div>

<lv-form [lvLabelColon]="false" class="formGroup filter-container"
    *ngIf="filterExcludeArr.length > 0 || filterIncludeArr.length > 0">
    <lv-form-item *ngIf="filterExcludeArr.length > 0">
        <lv-form-label>{{'common_exclude_label' | i18n}}</lv-form-label>
        <lv-form-control>
            <ng-container *ngTemplateOutlet='baseFilterTpl;context:{$implicit: filterExcludeArr}'>
            </ng-container>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item *ngIf="filterIncludeArr.length > 0">
        <lv-form-label>{{'common_include_label' | i18n}}</lv-form-label>
        <lv-form-control>
            <ng-container *ngTemplateOutlet='baseFilterTpl;context:{$implicit: filterIncludeArr}'>
            </ng-container>
        </lv-form-control>
    </lv-form-item>
</lv-form>

<ng-template #baseFilterTpl let-arr>
    <ng-container *ngIf="!!arr.length;else emptyTpl">
        <lv-form [lvLabelColon]="false" class="formGroup">
            <ng-container *ngFor="let item of arr">
                <ng-container *ngFor="let val of item?.content">
                    <lv-form-item>
                        <lv-form-label>
                            <span class="filter-header-color">{{item?.label}}</span>
                        </lv-form-label>
                        <lv-form-control>
                            <div class="filter-break">
                                {{val}}
                            </div>
                        </lv-form-control>
                    </lv-form-item>
                </ng-container>
            </ng-container>
        </lv-form>
    </ng-container>
    <ng-template #emptyTpl>
        --
    </ng-template>
</ng-template>